********************************************************************************
********************************************************************************
* This do file replicates all main figures on historical job ads: Figure 1
********************************************************************************
********************************************************************************

*******************************************************************************
*** Figure 1. Fraction of job advertisements with requirements for language
*** proficiency, all occupations and by skill level. 
*******************************************************************************

use Data/data_figures_annonser_lang_JHR, clear
drop if high_skill == .
egen lang_req_mentioned_all = mean(language_req_mentioned) , by(year)
egen lang_req_mentioned_low = mean(language_req_mentioned) if low_skill == 1 , by(year)
egen lang_req_mentioned_med = mean(language_req_mentioned)if medium_skill == 1, by(year) 
egen lang_req_mentioned_high = mean(language_req_mentioned) if high_skill == 1, by(year)

collapse lang_req_mentioned_all lang_req_mentioned_low lang_req_mentioned_med lang_req_mentioned_high , by(year)

twoway connected lang_req_mentioned_all lang_req_mentioned_low lang_req_mentioned_med lang_req_mentioned_high year, ///
ytitle("") ///
xtitle("") ///
ylabel(,nogrid) graphregion(color(gs16)) ///
xlabel(,nogrid) ///
legend(lab(1 "All") lab(2 "Low")lab(3 "Medium") lab(4 "High" ) color(black) cols(4)) ///
lcolor(1 "black" 2 "black" 3 "black" 4 "black") msymbol(D T S) ///
msize(small small small small) ///
mcolor(1 "black" 2 "black" 3 "black" 4 "black") 
graph save "Stata output\Adds in 17 occ Swedish by skill level.ghp", replace
